--馈已异求
local kuijiyiqiu = fk.CreateSkill {
    name = "mcdh_kuijiyiqiu"
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

kuijiyiqiu:addEffect(fk.EventPhaseEnd,{
    can_trigger =function (self, event, target, player, data)
        return player:hasSkill(kuijiyiqiu.name) and data.phase == Player.Play and #lib.getPublicCards(player) == 0
    end,
    on_cost=function (self, event, target, player, data)
        local room = player.room
        local cards =lib.askForPublicCard(room,player,player,1,1,kuijiyiqiu.name,true,"#kuijiyiqiu-public",".|.|.|.|.|trick,basic",true)
        if #cards ~= 0 then
            event:setCostData(self,cards[1])
            return true
        end
    end,
    on_use =function (self, event, target, player, data)
        local room = player.room
        local cardId = event:getCostData(self)
        local card = Fk:getCardById(cardId)
        local name = Fk:getCardById(cardId).name
        room:setCardMark(card,"@@mcdh_overt_card" , 1)
        local use = room:askToUseVirtualCard(player,{name=name,skill_name=kuijiyiqiu.name,extra_data={bypass_times=true,extraUse=true},prompt="#kuijiyiqiu-use:::"..name, skip=true})
        if use then
            room:useCard(use)
        else
            player:drawCards(1,kuijiyiqiu.name)   
        end
    end
})

Fk:loadTranslationTable{
    ["mcdh_kuijiyiqiu"]="馈已异求",
    [":mcdh_kuijiyiqiu"]= "每回合出牌阶段结束时，若你没有明置牌，你可以明置一张基本牌或普通锦囊牌，然后视为使用此牌或摸一张牌。",
    ["#kuijiyiqiu-public"]="馈已异求:明置一张基本牌或普通锦囊牌，然后视为使用此牌或摸一张牌。",
    ["#kuijiyiqiu-use"] = "馈已异求: 视为使用 %arg1 ,取消则摸一张牌"
}



return kuijiyiqiu